package com.yhcui.monitor.restful;

import com.yhcui.monitor.bean.OsInfo;
import com.yhcui.monitor.bean.Result;
import com.yhcui.monitor.logic.OsInfoLogic;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Slf4j
@RestController
@Api(tags = "查看信息")
public class OsInfoRestful {

    @Autowired
    private OsInfoLogic osInfoLogic;

    @ApiOperation(value = "查看单台机器信息", notes = "")
    @RequestMapping(value = {"/osinfo/{ip}", "/osinfo"}, method = RequestMethod.GET, produces = "application/json")
    public Result<List<OsInfo>> osInfo(@PathVariable(required = false) String ip) {
        log.info("ip:{}", ip);
        return Result.success(osInfoLogic.queryOsInfo(ip));
    }
}
